﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace HengTong.DataAccess.Migrations
{
    /// <inheritdoc />
    public partial class 增加学历证明附件 : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_SysActivitImages_SysActivityParticipation_ActivityParticipationId",
                table: "SysActivitImages");

            migrationBuilder.DropForeignKey(
                name: "FK_SysPersonContractFile_SysPersonContract_PersonContractId",
                table: "SysPersonContractFile");

            migrationBuilder.AlterColumn<Guid>(
                name: "PersonContractId",
                table: "SysPersonContractFile",
                type: "uniqueidentifier",
                nullable: true,
                oldClrType: typeof(Guid),
                oldType: "uniqueidentifier");

            migrationBuilder.AlterColumn<Guid>(
                name: "ActivityParticipationId",
                table: "SysActivitImages",
                type: "uniqueidentifier",
                nullable: true,
                oldClrType: typeof(Guid),
                oldType: "uniqueidentifier");

            migrationBuilder.CreateTable(
                name: "SysPersonEducationFile",
                columns: table => new
                {
                    ID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    PersonEducationId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    FileId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    Order = table.Column<int>(type: "int", nullable: false),
                    CreateTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    CreateBy = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    UpdateBy = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SysPersonEducationFile", x => x.ID);
                    table.ForeignKey(
                        name: "FK_SysPersonEducationFile_FileAttachments_FileId",
                        column: x => x.FileId,
                        principalTable: "FileAttachments",
                        principalColumn: "ID",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_SysPersonEducationFile_SysPersonEducation_PersonEducationId",
                        column: x => x.PersonEducationId,
                        principalTable: "SysPersonEducation",
                        principalColumn: "ID",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_SysPersonEducationFile_FileId",
                table: "SysPersonEducationFile",
                column: "FileId");

            migrationBuilder.CreateIndex(
                name: "IX_SysPersonEducationFile_PersonEducationId",
                table: "SysPersonEducationFile",
                column: "PersonEducationId");

            migrationBuilder.AddForeignKey(
                name: "FK_SysActivitImages_SysActivityParticipation_ActivityParticipationId",
                table: "SysActivitImages",
                column: "ActivityParticipationId",
                principalTable: "SysActivityParticipation",
                principalColumn: "ID");

            migrationBuilder.AddForeignKey(
                name: "FK_SysPersonContractFile_SysPersonContract_PersonContractId",
                table: "SysPersonContractFile",
                column: "PersonContractId",
                principalTable: "SysPersonContract",
                principalColumn: "ID");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_SysActivitImages_SysActivityParticipation_ActivityParticipationId",
                table: "SysActivitImages");

            migrationBuilder.DropForeignKey(
                name: "FK_SysPersonContractFile_SysPersonContract_PersonContractId",
                table: "SysPersonContractFile");

            migrationBuilder.DropTable(
                name: "SysPersonEducationFile");

            migrationBuilder.AlterColumn<Guid>(
                name: "PersonContractId",
                table: "SysPersonContractFile",
                type: "uniqueidentifier",
                nullable: false,
                defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
                oldClrType: typeof(Guid),
                oldType: "uniqueidentifier",
                oldNullable: true);

            migrationBuilder.AlterColumn<Guid>(
                name: "ActivityParticipationId",
                table: "SysActivitImages",
                type: "uniqueidentifier",
                nullable: false,
                defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
                oldClrType: typeof(Guid),
                oldType: "uniqueidentifier",
                oldNullable: true);

            migrationBuilder.AddForeignKey(
                name: "FK_SysActivitImages_SysActivityParticipation_ActivityParticipationId",
                table: "SysActivitImages",
                column: "ActivityParticipationId",
                principalTable: "SysActivityParticipation",
                principalColumn: "ID",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_SysPersonContractFile_SysPersonContract_PersonContractId",
                table: "SysPersonContractFile",
                column: "PersonContractId",
                principalTable: "SysPersonContract",
                principalColumn: "ID",
                onDelete: ReferentialAction.Cascade);
        }
    }
}
